package com.example.utils;

import java.util.Calendar;
import java.util.Date;

/*
 * @className: DateTimeUtils
 * @author: chentao
 * @date: 2025/7/25 8:32
 * @Version: 1.0
 * @description:
 */
public class DateTimeUtils {

    /***
     * 时间加秒
     * @param time
     * @param sec
     * @return
     */
    public static Date addSec(Date time, int sec) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(time);
        calendar.add(Calendar.SECOND, sec);
        return calendar.getTime();
    }

    /***
     * 时间加秒
     * @param sec 秒数
     * @return
     */
    public static Date addSec(int sec) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.SECOND, sec);
        return calendar.getTime();
    }
}
